//package cn.microservices.supplychain.system.service.stream;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.CommandLineRunner;
//import org.springframework.cloud.stream.function.StreamBridge;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.messaging.Message;
//import org.springframework.messaging.MessageHeaders;
//import org.springframework.messaging.support.MessageBuilder;
//import org.springframework.util.MimeTypeUtils;
//
//@Configuration
//public class EventSender<T> {
//    @Bean
//    public Demo demo() {
//        return new Demo();
//    }
//
//    class Demo implements CommandLineRunner {
//        @Autowired
//        StreamBridge streamBridge;
//
//        @Override
//        public void run(String... args) throws Exception {
//            final Message<T> message = MessageBuilder.withPayload("Body")
//                .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON)
//                .build();
//
//            // 第一个配置的是目的地
//            // 如果在yaml中有配置会发送到yaml中目的地
//            streamBridge.send("DEMO", message);
//        }
//    }
//}